﻿unit Search;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, R4FuncKeys, ToolWin, StdCtrls,FileInfo;



type
  TSearchResultEvent = procedure(Sender:TObject;SN :string) of object;        //定义事件
  TForm2 = class(TForm)
    Label1: TLabel;
    searchName: TEdit;
    R4Funckeys1: TR4Funckeys;
    R4FuncBtn1: TR4FuncBtn;
    R4FuncBtn2: TR4FuncBtn;
    R4FuncBtn3: TR4FuncBtn;
    R4FuncBtn4: TR4FuncBtn;
    R4FuncBtn5: TR4FuncBtn;
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure FormDestroy(Sender: TObject);
    procedure R4FuncBtn2Click(Sender: TObject);
    procedure R4FuncBtn4Click(Sender: TObject);

  private
    { Private declarations }
    MainFileList : TList;

    FOnSearchResult : TSearchResultEvent; // 处理结果
  public
    { Public declarations }
    property FileList : TList read MainFileList write MainFileList;

    property OnSearchResult : TSearchResultEvent read FOnSearchResult write FOnSearchResult;  //定义 OnSearchResult 用于通知父窗体
  end;

var
  Form2: TForm2;



implementation

{$R *.dfm}

procedure TForm2.FormDestroy(Sender: TObject);
begin
  //TForm2.Free;
end;

procedure TForm2.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  R4Funckeys1.FuncKey(Key);
end;

procedure TForm2.R4FuncBtn2Click(Sender: TObject);
begin
  Close;
end;

procedure TForm2.R4FuncBtn4Click(Sender: TObject);
var
  SN : string;
  I : Integer;
  IsFound : Integer;
  MyFileInfo : PFileInfo;
begin
  SN := searchName.Text;

  if Length(SN)<=0 then
  begin
    showmessage('The search content is empty');
    exit;
  end;

  //回传输入的检索内容给父窗体
  if Assigned(FOnSearchResult) then
  begin
    FOnSearchResult(Self,SN);
  end;

  ModalResult := mrOK;
end;



end.
